//
//  SecondViewController.m
//  UI_作业05
//
//  Created by zhuziming on 16/6/11.
//  Copyright © 2016年 zuzhiming. All rights reserved.
//

#import "SecondViewController.h"
#import "CustomButton.h"
@interface SecondViewController ()

@end

@implementation SecondViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    CustomButton *goBack = [CustomButton buttonWithType:UIButtonTypeSystem Frame:CGRectMake(100, 50, 175, 40) BackGroundImage:nil];
    [goBack setTitle:@"返回" forState:UIControlStateNormal];
    goBack.titleLabel.font = [UIFont systemFontOfSize:25.0f];
    [self.view addSubview:goBack];
    
    [goBack addTarget:self action:@selector(didClickedNextButton:) forControlEvents:UIControlEventTouchUpInside];
    
    [self createZombie];
    
    [self createSlider];
}

- (void)createZombie
{
    UIImageView *imageView = [[UIImageView alloc]init];
    imageView.tag = 1000;
    NSMutableArray *array = [NSMutableArray array];
    for (NSInteger i = 0; i < 22; i ++) {
        UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"Zombie%ld.tiff", i]];
        [array addObject:image];
    }
 
    imageView.animationImages = array;
    imageView.frame = CGRectMake(100, 200, 150, 144);
    [self.view addSubview:imageView];
    imageView.animationRepeatCount = 0;
    [imageView startAnimating];
    [imageView release];
    
}

- (void)createSlider
{
    UISlider *slider = [[UISlider alloc]initWithFrame:CGRectMake(50, 550, 275, 50)];
    slider.tag = 1001;
    slider.minimumValue = 0;
    slider.maximumValue = 1;
    slider.tintColor = [UIColor blueColor];
    slider.thumbTintColor = [UIColor redColor];
    [self.view addSubview:slider];
    [slider addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
    [slider release];
}

- (void)sliderAction:(UISlider *)slider
{
    
    UIImageView *ImageView = (UIImageView *)[self.view viewWithTag:1000];
    ImageView.animationDuration = slider.maximumValue - slider.value;
    [ImageView startAnimating];
}

- (void)didClickedNextButton:(CustomButton *)button
{
    [self dismissViewControllerAnimated:YES completion:nil];
}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
